#
# @lc app=leetcode.cn id=1078 lang=python3
#
# [1078] Bigram 分词
# 一上来局限于使用栈来实现，发现直接遍历就可以了

# @lc code=start
class Solution:
    def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
        text_list = text.split()
        result_list = []
        if first not in text_list or second not in text_list:   # 增加一步判断，提高效率
            return result_list
        for index in range(len(text_list)-2):
            if text_list[index] == first and text_list[index+1] == second:
                result_list.append(text_list[index+2])
                index += 2
        return result_list




# @lc code=end

